﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Finance.Entites;
using Finance.UI.ViewModels;

namespace Finance.UI.UserControls
{
    public partial class ItemSelector : UserControl
    {
        #region Public Properties

        public event EventHandler<SelectItemInformationEventArgs> OnItemSelected;

        #endregion

        public ItemSelector()
        {
            InitializeComponent();
            //this.Loaded += (o, e) => { InitializeDataContext(); };
        }

        private void InitializeDataContext()
        {
            //var R = new Random();
            //this.DataContext = new SelectorPageViewModel(
            //    "Payout Classification Selector",
            //    string.Empty,
            //    DataContextBuilder.InitialClassifications<PayoutClassification>(
            //    App.PayoutClassificationDataStore).ToArray());
        }

        private void SelectItem_Click(object sender, EventArgs e)
        {
            var siiEventArgs = new SelectItemInformationEventArgs();

            var itemDataContext = (sender as RadioButton).DataContext as DetailItemViewModel;
            siiEventArgs.SelectedItemHeaderName = itemDataContext.Title;
            siiEventArgs.SelectedItemName = itemDataContext.Name;

            if (OnItemSelected != null)
            {
                OnItemSelected(sender, siiEventArgs);
            }
        }
    }

    public class SelectItemInformationEventArgs : EventArgs
    {
        public string SelectedItemName { get; set; }
        public string SelectedItemHeaderName { get; set; }
    }
}
